#include "fig_award_tracker.h"


FIGAwardTracker&	FIGAwardTracker::Instance()
{
	static FIGAwardTracker	Inst;
	return Inst;
}

FIGAwardTracker::FIGAwardTracker() : m_StarObtained(0),
									 m_EnemiesKill(0),
									 m_LevelScore(0)
{

}

void		FIGAwardTracker::Reset()
{
	m_EnemiesKill = 0;
	m_StarObtained = 0;
	m_TotalStars = 0;
	m_TotalEnemies = 0;
	m_LevelScore = 0;

	for(int i = 0; i < FIGGameCenter::ACHIEVEMENT_C; i++)
	{
		m_AwardGotThisLevel[i] = false;
	}
}


void		FIGAwardTracker::Start(int TotalEnemies, int TotalStars)
{
	Reset();
	m_TotalEnemies = TotalEnemies;
	m_TotalStars = TotalStars;
	
}

int			FIGAwardTracker::GetStarObtainedPerc()
{
	if(m_TotalStars <= 0)
		return 0;

	float Temp1 = (float)m_StarObtained;
	float Temp2 = (float)m_TotalStars;

	float Temp3 = Temp1 / Temp2;

	int RetV = (int)(Temp3 * 100);
	if(RetV > 100)
		RetV = 100;

	return RetV;
	
}

int			FIGAwardTracker::GetEnemiesKilledPerc()
{
	if(m_TotalEnemies <= 0)
		return 0;

	float Temp1 = (float)m_EnemiesKill;
	float Temp2 = (float)m_TotalEnemies;

	float Temp3 = Temp1 / Temp2;

	int RetV = (int)(Temp3 * 100);
	if(RetV > 100)
		RetV = 100;

	return RetV;
		
}

void		FIGAwardTracker::EnemyKill(int ScoreToAdd)
{
	m_EnemiesKill++; 
	m_LevelScore += ScoreToAdd;
}